﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
    class DalChiTietHDN
    {
        internal static List<ChiTietHDN> GetListByMa(String MaHDN)
        {
            List<ChiTietHDN> result = new List<ChiTietHDN>();

            QLDCTTEntities da = new QLDCTTEntities();

            try
            {
                result = (from hd in da.ChiTietHDN
                          where hd.MaHDN == MaHDN
                          select hd).ToList();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return result;
        }

        internal static void Add(ChiTietHDN bizhdn)
        {
            try
            {
                ChiTietHDN hdn = new ChiTietHDN();
                hdn.MaHDN = bizhdn.MaHDN;
                hdn.ID_SP = bizhdn.ID_SP;
                hdn.SoLuong = bizhdn.SoLuong;

                QLDCTTEntities entities = new QLDCTTEntities();
                entities.ChiTietHDN.Add(hdn);

                entities.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
